home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12465 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.iadfw.net!usenet
  2. From: Mark Nelson <markn@airmail.net>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: calloc() - is there a C++ equivalent ?
  5. Date: Tue, 19 Mar 1996 22:04:21 -0600
  6. Organization: customer of Internet America
  7. Message-ID: <314F83C5.8AC@airmail.net>
  8. References: <4inkp1$je5@ncar.ucar.edu>
  9. NNTP-Posting-Host: dal32-09.ppp.iadfw.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  14.  
  15. James Adams wrote:
  16. > Hello,
  17. >         The subject line says it all - I want to allocate a block of
  18. > memory which I can count on being initialized to zero, as the calloc()
  19. > call in C will return.  Is there such a beast in C++, or will I have to
  20. > do the initialization programmatically ?
  21.  
  22. You will have to do the initialization programmatically.  If what you
  23. really need is just a block of raw memory initialized to zero, you
  24. probably are safe using calloc().  About the only thing that could
  25. potentially cause a problem is if you used calloc() to allocate the
  26. memory and then tried to use delete to free it.  Even that stands
  27. a pretty good chance of working okay given today's compilers.  
  28.  
  29. Use calloc()/free() in your C++ program and you should be okay.
  30.  
  31. Mark Nelson
  32. http://web2.airmail.net/markn
  33.